package cn.itcast.web.controller;

/*
*       抽取公共的属性
* */

import cn.itcast.domain.system.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class BaseController {

    //注入request
    @Autowired
    protected HttpServletRequest request;

    //注入response
    @Autowired
    protected HttpServletResponse response;

    //注入Session
    @Autowired
    protected  HttpSession session;

    //部门id
    public  String  getLoginCompanyId(){
        //获取存储在session中的数据
        User user =(User) session.getAttribute("loginUser");
        return user.getCompanyId();
    }
    //获取企业名称
    public String getLoginCompanyName(){
        //获取存储在session中的数据
        User user =(User)session.getAttribute("loginUser");
        return user.getCompanyName();
    }

    //获取当前登录用户
    public User getLoginUser(){
        return (User)session.getAttribute("loginUser");
    }
}
